<template>
	<div>
		<el-breadcrumb separator-class="el-icon-arrow-right">
			<el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
			<el-breadcrumb-item>收废品</el-breadcrumb-item>
			<el-breadcrumb-item>门店管理</el-breadcrumb-item>
		</el-breadcrumb>
		<el-link :underline="false" style="font-size: 30px;">全部门店</el-link>&nbsp&nbsp
		<el-link :underline="false" style="font-size: 30px;">上架中</el-link>&nbsp&nbsp
		<el-link :underline="false" style="font-size: 30px;">已下架</el-link>
		<el-form :inline="true" :model="storeData">
			<el-form-item label="门店名称:">
				<el-input v-model="storeData.shopName"></el-input>
			</el-form-item>
			<el-form-item label="门店手机号:">
				<el-input v-model="storeData.shopPhone"></el-input>
			</el-form-item>
			<el-form-item label="提交日期:">
				<el-date-picker value-format="yyyy-MM-dd hh:mm:ss" v-model="dataValue" type="daterange" align="right"
					unlink-panels range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"
					:picker-options="pickerOptions">
				</el-date-picker>
			</el-form-item>
			<el-form-item>
				<el-button @click="getinfo" type="primary">搜索</el-button>
			</el-form-item><br />
			<el-form-item>
				<el-button type="primary">新增门店</el-button>
				<el-dialog :title="title" :visible.sync="dialogFormVisible" @close="cancle">
					<el-form :model="communityData">
						<el-form-item label="小区名称" label-width="80px" style="margin-top: 10px;">
							<el-input v-model="communityData.communityName"></el-input>
						</el-form-item>
						<el-form-item label="所属地区" label-width="80px" style="margin-top: 10px;">
							<el-cascader v-model="address" :options="citys" @change="handleChange"></el-cascader>
						</el-form-item>
						<el-form-item label-width="80px" style="margin-top: 10px;">
							<el-input placeholder="详细地址" v-model="communityData.communityCoordinates"></el-input>
						</el-form-item>
						<el-form-item label="门店坐标" label-width="80px" style="margin-top: 10px;">
							<el-button @click="getLocation">获取位置</el-button>
							<!--放置经纬度信息-->
							<span
								v-show="show">{{communityData.communityLatitude}},{{communityData.communityLongitude}}</span>
						</el-form-item>
					</el-form>
					<div slot="footer" class="dialog-footer">
						<el-button @click="cancle">取消</el-button>
						<el-button type="primary" @click="updateCommunity">确 定</el-button>
					</div>
				</el-dialog>
			</el-form-item>
		</el-form>
		<el-table :header-cell-style="{fontSize: '14px', backgroundColor: '#1890FF',color:'#ffffff'}" :data="tableData"
			border style="width: 100%">
			<el-table-column prop="shopName" label="门店" width="180">
			</el-table-column>
			<el-table-column prop="shopId" label="ID" width="180">
			</el-table-column>
			<el-table-column prop="shopPhone" label="门店手机号" width="180">
			</el-table-column>
			<el-table-column prop="shopAddress" label="门店地址" width="180">
			</el-table-column>
			<el-table-column prop="shopDescribe" label="营业时间" width="180">
			</el-table-column>
			<el-table-column prop="createTime" label="关联小区" width="180">
			</el-table-column>
			<el-table-column prop="shopOrderCount" label="订单总数" width="180">
			</el-table-column>
			<el-table-column prop="communityShopCount" label="提交方式" width="180">
			</el-table-column>
			<el-table-column label="状态"><el-button @click="del" type="text" size="small">删除</el-button>
			</el-table-column>

			<el-table-column fixed="right" label="操作" width="100">
				<template slot-scope="scope">
					<el-button @click="handleClick" type="text" size="small">查看关联门店</el-button>
					<el-button @click="ed" type="text" size="small">编辑小区</el-button>
					<el-button @click="del" type="text" size="small">删除</el-button>
				</template>
			</el-table-column>
		</el-table>
		<el-row style="margin-top: 10px;">
			<div class="block">
				<el-pagination layout="prev, pager, next,jumper,total,sizes" @size-change="handleSizeChange"
					@current-change="handleCurrentChange" :current-page="queryInfo.pageNum" :page-sizes="[1,5,10,20]"
					:page-size="queryInfo.pageSize" :total="total">
				</el-pagination>
			</div>
		</el-row>
	</div>
</template>

<script>
	export default {
		data() {
			
			return {
				storeData: { // 小区信息
					shopAddress: "",
					shopCity: "",
					shopDescribe: "",
					shopDistrict: "",
					shopImage: "",
					shopLatitude: "",
					shopLongitude: "",
					shopName: "",
					shopPhone: "",
					shopProvince: ""
				},
				total: '',
				tableData: [],
				queryInfo: {
					communityName: '',
					startTime: '',
					endTime: '',
					pageNum: 1,
					pageSize: 10,
					name: ''
				},
				dataValue: [],
				input: '',
				pickerOptions: {
					shortcuts: [{
						text: '最近一周',
						onClick(picker) {
							const end = new Date();
							const start = new Date();
							start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
							picker.$emit('pick', [start, end]);
						}
					}, {
						text: '最近一个月',
						onClick(picker) {
							const end = new Date();
							const start = new Date();
							start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
							picker.$emit('pick', [start, end]);
						}
					}, {
						text: '最近三个月',
						onClick(picker) {
							const end = new Date();
							const start = new Date();
							start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
							picker.$emit('pick', [start, end]);
						}
					}]
				},
				value1: '',
				value2: ''
			}
		},
		methods: {
			handleClick() {
				// 处理查看关联门店的逻辑
				console.log('查看关联门店');
			},
			ed() {
				// 处理编辑小区的逻辑
				console.log('编辑小区');
			},
			del() {
				// 处理删除小区的逻辑
				console.log('删除');
			},
			handleSizeChange(val) {
				this.queryInfo.pageSize = val;
				this.queryInfo.pageNum = 1;
				this.getinfo();
			},
			handleCurrentChange(val) {
				this.queryInfo.pageNum = val;
				this.getinfo();
			},
			getinfo() {
				console.log(this.dataValue[0])
				console.log(this.dataValue[1])
				this.$http.get('shop/querySearchShopList', {
						params: this.queryInfo
					})
					.then((res) => {
						this.tableData = res.data.data.list;
						this.total = res.data.data.total;
						if (res.data.status == 200) {
							console.log(res.data.data.list)
						} else {
							this.$message.error('服务器接口异常')
						}
					})
			}
		},
		mounted() {
			this.getinfo();
		},
		watch: {
			dataValue() {
				if (this.dataValue) {
					this.queryInfo.startTime = this.dataValue[0];
					this.queryInfo.endTime = this.dataValue[1]
				} else {
					this.queryInfo.startTime = '',
						this.queryInfo.endTime = ''
				}
			}
		}
	}
</script>

<style>
</style>